/**
 * 字段配置文件
 * 定义不同数据类型的字段显示配置
 */

// 螺丝拧紧类型配置
const screwConfig = {
  fields: {
    // CCD检查结果
    screwCCDcheckResult: { label: '螺丝相机检查结果', type: 'result', order: 1 },
    screwCCDResult: { label: '螺丝相机检查结果', type: 'result', order: 1 },

    // 拧紧结果
    tightenResult01: { label: '1#螺丝拧紧结果', type: 'result', order: 10 },
    tightenResult02: { label: '2#螺丝拧紧结果', type: 'result', order: 11 },
    tightenResult03: { label: '3#螺丝拧紧结果', type: 'result', order: 12 },
    tightenResult04: { label: '4#螺丝拧紧结果', type: 'result', order: 13 },
    tightenResult05: { label: '5#螺丝拧紧结果', type: 'result', order: 14 },
    tightenResult06: { label: '6#螺丝拧紧结果', type: 'result', order: 15 },
    tightenResult07: { label: '7#螺丝拧紧结果', type: 'result', order: 16 },
    tightenResult08: { label: '8#螺丝拧紧结果', type: 'result', order: 17 },
    tightenResult09: { label: '9#螺丝拧紧结果', type: 'result', order: 18 },
    tightenResult10: { label: '10#螺丝拧紧结果', type: 'result', order: 19 },
    tightenResult11: { label: '11#螺丝拧紧结果', type: 'result', order: 20 },
    tightenResult12: { label: '12#螺丝拧紧结果', type: 'result', order: 21 },

    // 批次号
    screwBatchNo: { label: '螺丝批次号', type: 'bytes', order: 22 },
    screwBtachNo: { label: '螺丝批次号', type: 'bytes', order: 23 }, // 拼写错误的字段名
    sealingRing: { label: '密封圈批次号', type: 'bytes', order: 24 }, // 拼写错误的字段名

    // 转接板物料码
    adapterBoardMaterialNo: { label: '转接板追溯码', type: 'bytes', order: 25 },

    // 程序号
    programNo01: { label: '1#螺丝拧紧程序号', type: 'number', order: 30 },
    programNo02: { label: '2#螺丝拧紧程序号', type: 'number', order: 31 },
    programNo03: { label: '3#螺丝拧紧程序号', type: 'number', order: 32 },
    programNo04: { label: '4#螺丝拧紧程序号', type: 'number', order: 33 },
    programNo05: { label: '5#螺丝拧紧程序号', type: 'number', order: 34 },
    programNo06: { label: '6#螺丝拧紧程序号', type: 'number', order: 35 },
    programNo07: { label: '7#螺丝拧紧程序号', type: 'number', order: 36 },
    programNo08: { label: '8#螺丝拧紧程序号', type: 'number', order: 37 },
    programNo09: { label: '9#螺丝拧紧程序号', type: 'number', order: 38 },
    programNo10: { label: '10#螺丝拧紧程序号', type: 'number', order: 39 },
    programNo11: { label: '11#螺丝拧紧程序号', type: 'number', order: 40 },
    programNo12: { label: '12#螺丝拧紧程序号', type: 'number', order: 41 },

    // 扭矩相关
    minTorque01: { label: '1#螺丝拧紧最小扭矩', type: 'unit', format: { unit: 'N·m', decimals: 2 }, order: 50 },
    actTorque01: { label: '1#螺丝拧紧最终扭矩', type: 'unit', format: { unit: 'N·m', decimals: 2 }, order: 51 },
    maxTorque01: { label: '1#螺丝拧紧最大扭矩', type: 'unit', format: { unit: 'N·m', decimals: 2 }, order: 52 },

    minTorque02: { label: '2#螺丝拧紧最小扭矩', type: 'unit', format: { unit: 'N·m', decimals: 2 }, order: 53 },
    actTorque02: { label: '2#螺丝拧紧最终扭矩', type: 'unit', format: { unit: 'N·m', decimals: 2 }, order: 54 },
    maxTorque02: { label: '2#螺丝拧紧最大扭矩', type: 'unit', format: { unit: 'N·m', decimals: 2 }, order: 55 },

    minTorque03: { label: '3#螺丝拧紧最小扭矩', type: 'unit', format: { unit: 'N·m', decimals: 2 }, order: 56 },
    actTorque03: { label: '3#螺丝拧紧最终扭矩', type: 'unit', format: { unit: 'N·m', decimals: 2 }, order: 57 },
    maxTorque03: { label: '3#螺丝拧紧最大扭矩', type: 'unit', format: { unit: 'N·m', decimals: 2 }, order: 58 },

    minTorque04: { label: '4#螺丝拧紧最小扭矩', type: 'unit', format: { unit: 'N·m', decimals: 2 }, order: 59 },
    actTorque04: { label: '4#螺丝拧紧最终扭矩', type: 'unit', format: { unit: 'N·m', decimals: 2 }, order: 60 },
    maxTorque04: { label: '4#螺丝拧紧最大扭矩', type: 'unit', format: { unit: 'N·m', decimals: 2 }, order: 61 },

    minTorque05: { label: '5#螺丝拧紧最小扭矩', type: 'unit', format: { unit: 'N·m', decimals: 2 }, order: 62 },
    actTorque05: { label: '5#螺丝拧紧最终扭矩', type: 'unit', format: { unit: 'N·m', decimals: 2 }, order: 63 },
    maxTorque05: { label: '5#螺丝拧紧最大扭矩', type: 'unit', format: { unit: 'N·m', decimals: 2 }, order: 64 },

    minTorque06: { label: '6#螺丝拧紧最小扭矩', type: 'unit', format: { unit: 'N·m', decimals: 2 }, order: 65},
    actTorque06: { label: '6#螺丝拧紧最终扭矩', type: 'unit', format: { unit: 'N·m', decimals: 2 }, order: 66 },
    maxTorque06: { label: '6#螺丝拧紧最大扭矩', type: 'unit', format: { unit: 'N·m', decimals: 2 }, order: 67 },

    minTorque07: { label: '7#螺丝拧紧最小扭矩', type: 'unit', format: { unit: 'N·m', decimals: 2 }, order: 68 },
    actTorque07: { label: '7#螺丝拧紧最终扭矩', type: 'unit', format: { unit: 'N·m', decimals: 2 }, order: 69 },
    maxTorque07: { label: '7#螺丝拧紧最大扭矩', type: 'unit', format: { unit: 'N·m', decimals: 2 }, order: 70 },

    minTorque08: { label: '8#螺丝拧紧最小扭矩', type: 'unit', format: { unit: 'N·m', decimals: 2 }, order: 71 },
    actTorque08: { label: '8#螺丝拧紧最终扭矩', type: 'unit', format: { unit: 'N·m', decimals: 2 }, order: 72 },
    maxTorque08: { label: '8#螺丝拧紧最大扭矩', type: 'unit', format: { unit: 'N·m', decimals: 2 }, order: 73 },

    minTorque09: { label: '9#螺丝拧紧最小扭矩', type: 'unit', format: { unit: 'N·m', decimals: 2 }, order: 74 },
    actTorque09: { label: '9#螺丝拧紧最终扭矩', type: 'unit', format: { unit: 'N·m', decimals: 2 }, order: 75 },
    maxTorque09: { label: '9#螺丝拧紧最大扭矩', type: 'unit', format: { unit: 'N·m', decimals: 2 }, order: 76 },

    minTorque10: { label: '10#螺丝拧紧最小扭矩', type: 'unit', format: { unit: 'N·m', decimals: 2 }, order: 77 },
    actTorque10: { label: '10#螺丝拧紧最终扭矩', type: 'unit', format: { unit: 'N·m', decimals: 2 }, order: 78 },
    maxTorque10: { label: '10#螺丝拧紧最大扭矩', type: 'unit', format: { unit: 'N·m', decimals: 2 }, order: 79 },

    minTorque11: { label: '11#螺丝拧紧最小扭矩', type: 'unit', format: { unit: 'N·m', decimals: 2 }, order: 80 },
    actTorque11: { label: '11#螺丝拧紧最终扭矩', type: 'unit', format: { unit: 'N·m', decimals: 2 }, order: 81 },
    maxTorque11: { label: '11#螺丝拧紧最大扭矩', type: 'unit', format: { unit: 'N·m', decimals: 2 }, order: 82 },

    minTorque12: { label: '12#螺丝拧紧最小扭矩', type: 'unit', format: { unit: 'N·m', decimals: 2 }, order: 83 },
    actTorque12: { label: '12#螺丝拧紧最终扭矩', type: 'unit', format: { unit: 'N·m', decimals: 2 }, order: 84 },
    maxTorque12: { label: '12#螺丝拧紧最大扭矩', type: 'unit', format: { unit: 'N·m', decimals: 2 }, order: 85 },

    // 角度相关
    minAngle01: { label: '1#螺丝拧紧最小角度', type: 'unit', format: { unit: '°', decimals: 1 }, order: 86 },
    actAngle01: { label: '1#螺丝拧紧最终角度', type: 'unit', format: { unit: '°', decimals: 1 }, order: 87 },
    maxAngle01: { label: '1#螺丝拧紧最大角度', type: 'unit', format: { unit: '°', decimals: 1 }, order: 88 },

    minAngle02: { label: '2#螺丝拧紧最小角度', type: 'unit', format: { unit: '°', decimals: 1 }, order: 89 },
    actAngle02: { label: '2#螺丝拧紧最终角度', type: 'unit', format: { unit: '°', decimals: 1 }, order: 90 },
    maxAngle02: { label: '2#螺丝拧紧最大角度', type: 'unit', format: { unit: '°', decimals: 1 }, order: 91 },

    minAngle03: { label: '3#螺丝拧紧最小角度', type: 'unit', format: { unit: '°', decimals: 1 }, order: 92 },
    actAngle03: { label: '3#螺丝拧紧最终角度', type: 'unit', format: { unit: '°', decimals: 1 }, order: 93 },
    maxAngle03: { label: '3#螺丝拧紧最大角度', type: 'unit', format: { unit: '°', decimals: 1 }, order: 94 },

    minAngle04: { label: '4#螺丝拧紧最小角度', type: 'unit', format: { unit: '°', decimals: 1 }, order: 95 },
    actAngle04: { label: '4#螺丝拧紧最终角度', type: 'unit', format: { unit: '°', decimals: 1 }, order: 96 },
    maxAngle04: { label: '4#螺丝拧紧最大角度', type: 'unit', format: { unit: '°', decimals: 1 }, order: 97 },

    minAngle05: { label: '5#螺丝拧紧最小角度', type: 'unit', format: { unit: '°', decimals: 1 }, order: 98 },
    actAngle05: { label: '5#螺丝拧紧最终角度', type: 'unit', format: { unit: '°', decimals: 1 }, order: 99 },
    maxAngle05: { label: '5#螺丝拧紧最大角度', type: 'unit', format: { unit: '°', decimals: 1 }, order: 100 },

    minAngle06: { label: '6#螺丝拧紧最小角度', type: 'unit', format: { unit: '°', decimals: 1 }, order: 101 },
    actAngle06: { label: '6#螺丝拧紧最终角度', type: 'unit', format: { unit: '°', decimals: 1 }, order: 102 },
    maxAngle06: { label: '6#螺丝拧紧最大角度', type: 'unit', format: { unit: '°', decimals: 1 }, order: 103 },

    minAngle07: { label: '7#螺丝拧紧最小角度', type: 'unit', format: { unit: '°', decimals: 1 }, order: 104 },
    actAngle07: { label: '7#螺丝拧紧最终角度', type: 'unit', format: { unit: '°', decimals: 1 }, order: 105 },
    maxAngle07: { label: '7#螺丝拧紧最大角度', type: 'unit', format: { unit: '°', decimals: 1 }, order: 106 },

    minAngle08: { label: '8#螺丝拧紧最小角度', type: 'unit', format: { unit: '°', decimals: 1 }, order: 107 },
    actAngle08: { label: '8#螺丝拧紧最终角度', type: 'unit', format: { unit: '°', decimals: 1 }, order: 108 },
    maxAngle08: { label: '8#螺丝拧紧最大角度', type: 'unit', format: { unit: '°', decimals: 1 }, order: 109 },

    minAngle09: { label: '9#螺丝拧紧最小角度', type: 'unit', format: { unit: '°', decimals: 1 }, order: 110 },
    actAngle09: { label: '9#螺丝拧紧最终角度', type: 'unit', format: { unit: '°', decimals: 1 }, order: 111 },
    maxAngle09: { label: '9#螺丝拧紧最大角度', type: 'unit', format: { unit: '°', decimals: 1 }, order: 112 },

    minAngle10: { label: '10#螺丝拧紧最小角度', type: 'unit', format: { unit: '°', decimals: 1 }, order: 113 },
    actAngle10: { label: '10#螺丝拧紧最终角度', type: 'unit', format: { unit: '°', decimals: 1 }, order: 114 },
    maxAngle10: { label: '10#螺丝拧紧最大角度', type: 'unit', format: { unit: '°', decimals: 1 }, order: 115 },

    minAngle11: { label: '11#螺丝拧紧最小角度', type: 'unit', format: { unit: '°', decimals: 1 }, order: 116 },
    actAngle11: { label: '11#螺丝拧紧最终角度', type: 'unit', format: { unit: '°', decimals: 1 }, order: 117 },
    maxAngle11: { label: '11#螺丝拧紧最大角度', type: 'unit', format: { unit: '°', decimals: 1 }, order: 118 },

    minAngle12: { label: '12#螺丝拧紧最小角度', type: 'unit', format: { unit: '°', decimals: 1 }, order: 119 },
    actAngle12: { label: '12#螺丝拧紧最终角度', type: 'unit', format: { unit: '°', decimals: 1 }, order: 120 },
    maxAngle12: { label: '12#螺丝拧紧最大角度', type: 'unit', format: { unit: '°', decimals: 1 }, order: 121 },
  }
}

// 电阻测试类型配置
const resistanceConfig = {
  fields: {
    testResistanceResult01: { label: '安全接地1测试结果', type: 'result', order: 1 },
    testResistanceResult02: { label: '安全接地2测试结果', type: 'result', order: 2 },
    testResistanceResult03: { label: '安全接地3测试结果', type: 'result', order: 3 },
    testDielectricResult: { label: '绝缘电阻测试结果', type: 'result', order: 4 },
    testHeightVoltageResult: { label: '直流耐压测试结果', type: 'result', order: 5 },

    testProgramNo: { label: '测试程序号', type: 'number', order: 10 },

    testResistance01: { label: '安全接地1电阻值', type: 'unit', format: { unit: '', decimals: 3 }, order: 20 },
    testUnit01: { label: '安全接地1电阻值单位', type: 'bytes', order: 21 },
    testResistanceMax01: { label: '安全接地1电阻最大值', type: 'unit', format: { unit: 'Ω', decimals: 3 }, order: 22 },
    testResistanceMin01: { label: '安全接地1电阻最小值', type: 'unit', format: { unit: 'Ω', decimals: 3 }, order: 23 },

    testResistance02: { label: '安全接地2电阻值', type: 'unit', format: { unit: '', decimals: 3 }, order: 30 },
    testUnit02: { label: '安全接地2电阻值单位', type: 'bytes', order: 31 },
    testResistanceMax02: { label: '安全接地2电阻最大值', type: 'unit', format: { unit: 'Ω', decimals: 3 }, order: 32 },
    testResistanceMin02: { label: '安全接地2电阻最小值', type: 'unit', format: { unit: 'Ω', decimals: 3 }, order: 33 },

    testResistance03: { label: '安全接地3电阻值', type: 'unit', format: { unit: '', decimals: 3 }, order: 40 },
    testUnit03: { label: '安全接地3电阻值单位', type: 'bytes', order: 41 },
    testResistanceMax03: { label: '安全接地3电阻最大值', type: 'unit', format: { unit: 'Ω', decimals: 3 }, order: 42 },
    testResistanceMin03: { label: '安全接地3电阻最小值', type: 'unit', format: { unit: 'Ω', decimals: 3 }, order: 43 },

    testDielectric: { label: '绝缘电阻值', type: 'unit', format: { unit: '', decimals: 2 }, order: 50 },
    testDielectricUnit: { label: '绝缘电阻值单位', type: 'bytes', order: 51 },
    testDielectricMax: { label: '绝缘电阻最大值', type: 'unit', format: { unit: 'MΩ', decimals: 2 }, order: 52 },
    testDielectricMin: { label: '绝缘电阻最小值', type: 'unit', format: { unit: 'MΩ', decimals: 2 }, order: 53 },

    testHeightVoltage: { label: '耐压测试漏电流值', type: 'unit', format: { unit: '', decimals: 2 }, order: 60 },
    testHeightVoltageUnit: { label: '耐压测试漏电流值单位', type: 'bytes', order: 61 },
    testHeightVoltageMax: { label: '耐压测试漏电流最大值', type: 'unit', format: { unit: 'mA', decimals: 2 }, order: 62 },
    testHeightVoltageMin: { label: '耐压测试漏电流最小值', type: 'unit', format: { unit: 'mA', decimals: 2 }, order: 63 }
  }
}

// 上料类型配置
const loadConfig = {
  fields: {
    partLoadResult: { label: '上料结果', type: 'result', order: 1 },
    partCCDResult: { label: '涂胶相机检测结果', type: 'result', order: 2 },
    partCCDCheckResult: { label: '上料相机检测结果', type: 'result', order: 3 },

    thinFilmCapacitorMaterialNo: { label: '薄膜电容追溯码', type: 'bytes', order: 10 },
    filterCapacitorMaterialNo: { label: '滤波组件追溯码', type: 'bytes', order: 11 },

    housingMaterialNo: { label: '壳体追溯码', type: 'bytes', order: 20 },
    controllerMaterialNo: { label: '主控板盖追溯码', type: 'bytes', order: 21 },
    phaseMaterialNo: { label: '三相盖板追溯码', type: 'bytes', order: 22 },
    wireMaterialNo: { label: '低压线束盖板追溯码', type: 'bytes', order: 23 },
    busbarMaterialNo: { label: '母线盖板追溯码', type: 'bytes', order: 24 }
  }
}

// 涂胶类型配置
const glueConfig = {
  fields: {
    glueHousingResult: { label: '壳体涂胶结果', type: 'result', order: 1 },
    glueControllerResult: { label: '主控板涂胶结果', type: 'result', order: 2 },
    gluePhaseResult: { label: '三相盖板涂胶结果', type: 'result', order: 3 },
    glueWireResult: { label: '低压线束涂胶结果', type: 'result', order: 4 },
    glueBusbarResult: { label: '母线涂胶结果', type: 'result', order: 5 },

    housingGlueResult: { label: '工件涂胶结果', type: 'result', order: 6 },
    glueCCDResult: { label: '涂胶相机检测结果', type: 'result', order: 7 },

    glueBatchNo: { label: '胶水批次号', type: 'bytes', order: 10 }
  }
}

// 清洗类型配置
const cleanConfig = {
  fields: {
    housingPlasmaResult: { label: '壳体等离子清洗结果', type: 'result', order: 1 },
    controllerPlasmaResult: { label: '主控板等离子清洗结果', type: 'result', order: 2 },
    phasePlasmaResult: { label: '三相盖板等离子清洗结果', type: 'result', order: 3 },
    wirePlasmaResult: { label: '低压线束等离子清洗结果', type: 'result', order: 4 },
    busbarPlasmaResult: { label: '母线等离子清洗结果', type: 'result', order: 5 },
    tesFillPressureResult: { label: '水道充气压力结果', type: 'result', order: 6 },
    testLeakageResult: { label: '水道气密泄露结果', type: 'result', order: 7 }
  }
}

// 相机检测类型配置
const cameraConfig = {
  fields: {
    cameraResult01: { label: '1#相机检测结果', type: 'result', order: 1 },
    cameraResult02: { label: '2#相机检测结果', type: 'result', order: 2 },
    cameraResult03: { label: '3#相机检测结果', type: 'result', order: 3 },

    oringCCDResult: { label: 'O型圈相机检测结果', type: 'result', order: 10 },
    partCCDResult1: { label: '上料结果', type: 'result', order: 11 },
    partCCDResult01: { label: '三相铜排', type: 'result', order: 12 },
    partCCDResult02: { label: '薄膜电容', type: 'result', order: 13 },
    partCCDResult03: { label: '滤波器', type: 'result', order: 14 },
    partCCDResult04: { label: '连接器', type: 'result', order: 15 },
    partCCDResult05: { label: '线束插座', type: 'result', order: 16 },
    partCCDResult06: { label: 'PCB板', type: 'result', order: 17 },
    partCCDResult07: { label: 'PCB板锁紧螺丝（IGBT）', type: 'result', order: 18 },
    partCCDResult08: { label: 'IGBT锁紧螺丝', type: 'result', order: 19 },
    partCCDResult09: { label: 'PCB板锁紧螺丝（Hous）', type: 'result', order: 20 },
    partCCDResult10: { label: '薄膜电容螺丝', type: 'result', order: 21 },
    partCCDResult11: { label: '三相铜排锁紧螺丝', type: 'result', order: 22 },
    partCCDResult12: { label: '连接器螺丝', type: 'result', order: 23 }
  }
}

// 默认配置
const defaultConfig = {
  fields: {}
}

// 配置映射
const configMap = {
  screw: screwConfig,
  resistance: resistanceConfig,
  load: loadConfig,
  glue: glueConfig,
  clean: cleanConfig,
  camera: cameraConfig,
  default: defaultConfig
}

/**
 * 获取字段配置
 * @param {string} dataType 数据类型
 * @returns {object} 字段配置
 */
export function getFieldConfig(dataType) {
  return configMap[dataType] || defaultConfig
}

/**
 * 获取所有可用的数据类型
 * @returns {array} 数据类型列表
 */
export function getAvailableDataTypes() {
  return Object.keys(configMap).filter(key => key !== 'default')
}
